<div id="main-form">
	<? if($message > 0){ ?>
		<div id="message_box">
			<p class="img"></p>
			<p class="txt">
				<? if($message == 1){
						echo "You have successfully added a new user category.";
					}elseif($message == 2){
						echo "You have successfully updated user category.";
					}
				?>
			</p>
		</div>

	<? }else{ ?>

		<form name="submitForm" id="submitForm" method="POST" action="<?=$_SERVER['REQUEST_URI']?>">
			<input type="hidden" name="id" id="id" value="<?=$category_id;?>">
			<div>
				<ul class="singleColRows">
					<li class="leftcol">Label</li>
					<li class="rightcol">
						<input type="text" name="label" id="label" value="<?=$row['label']?>">
					</li>
				</ul>
				<ul class="singleColRows">
					<li class="leftcol">Alias / Acronym</li>
					<li class="rightcol">
						<input type="text" name="alias" id="alias" value="<?=$row['alias']?>">
					</li>
				</ul>
				<ul class="singleColRows">
					<li class="leftcol">Status</li>
					<li class="rightcol">
						<input type="radio" name="active" value="1" <?=($row['active'] == 1)?'checked':''?> > Active 
						<input type="radio" name="active" value="0" <?=($row['active'] == 0)?'checked':''?> > Inactive
					</li>
				</ul>

				<h2 class="singlerow">PERMISSIONS</h2>
				<ul class="singleColRows">
					<input type="hidden" name="access_all" id="access_all" value="0">
					<input type="hidden" name="access_group" id="access_group" value="0">
					<input type="hidden" name="access_restriction" id="access_restricted" value="0">
					<li>
						<input type="radio" name="permission" value="1" <?=($row['permission'] == 1)?'checked':''?> > Root (has access to all functionalities and all data) <br/>
						<input type="radio" name="permission" value="2" <?=($row['permission'] == 2)?'checked':''?> > Group Administrator <br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
						(Add, Edit, View functionalities available but limited only to data on his group) <br/>
						<input type="radio" name="permission" value="3" <?=($row['permission'] == 3)?'checked':''?> > Restricted (selected permissions, limited to his own data) <br/>
					</li>
				</ul>
				<ul class="singleColRows" id="restriction" style="<?=($row['permission'] == 3)?'display:block':'display:none';?>">
					<li class="leftcol">&nbsp;</li>
					<li class="rightcol">
						<input type="checkbox" name="allow_add" id="allow_add" value="1" <?=($row['allow_add'] == 1)?'checked':''?> > Allow Add Functionality <br/>
						<input type="checkbox" name="allow_view" id="allow_view" value="1" <?=($row['allow_view'] == 1)?'checked':''?> > Allow View Details Functionality <br/>
					</li> 
				</ul>
				<ul class="singleColRows">
					<li class="leftcol">&nbsp;</li>
					<li class="rightcol">
						<p class="buttons_elements">
							<input type="submit" class="form-button btn" id="submitBtn" value="Save">
							<input type="button" class="form-button btn" id="cancelBtn" value="Cancel">
						</p>
					</li>
				</ul>
			</div>
		</form>
	<? } ?>
</div>

<script type="text/javascript">
	$(document).ready(function() {
	    $("input[name=permission]:radio").change(function() {
	    	var radval = $('input:radio[name=permission]:checked').val();
	    	if(radval == 1){
	    		$('#access_all').val(1);
	    		$('#restriction').hide();
	    	}else if(radval == 2){
	    		$('#access_group').val(1);
	    		$('#restriction').hide();
	    	}else if(radval == 3){
	    		$('#access_restriction').val(1);
	    		$('#restriction').show();
	    	}
		});
	});
</script>